<style scoped>
    @import 'styles/common.css';
    #maxdiv{
        position: fixed;
        height: 100%;
        width: 100%;
    }
</style>
<template>
  <div class="layout" :class="{'layout-hide-text': spanLeft < 4}">
        <Row id="maxdiv" type="flex">
            <i-col :span="spanLeft" class="layout-menu-left">
                    <Menu active-name="1-2" theme="dark"  width="auto" @on-select="routeTo" :open-names="['1']">
                    <div class="layout-logo-left"></div>
                    <Submenu name="1">
                        <template slot="title">
                            <Icon type="ios-navigate"></Icon>
                            <span class="layout-text" :size="iconSize">系统管理</span>
                        </template>
                        <Menu-item name="/users/list"  class="layout-text" href="/users/list">用户管理</Menu-item>
                        <Menu-item name="1-2"  class="layout-text">角色管理</Menu-item>
                        <Menu-item name="1-3"  class="layout-text">菜单管理</Menu-item>
                    </Submenu>
                    <Submenu name="2">
                        <template slot="title">
                            <Icon type="ios-keypad"></Icon>
                            <span class="layout-text" :size="iconSize">导航二</span>
                        </template>
                        <Menu-item name="2-1"  class="layout-text">选项 1</Menu-item>
                        <Menu-item name="2-2"  class="layout-text">选项 2</Menu-item>
                    </Submenu>
                    <Submenu name="3">
                        <template slot="title">
                            <Icon type="ios-analytics"></Icon>
                            <span class="layout-text" :size="iconSize">导航三</span>
                        </template>
                        <Menu-item name="3-1"  class="layout-text">选项 1</Menu-item>
                        <Menu-item name="3-2"  class="layout-text">选项 2</Menu-item>
                    </Submenu>
                     <Menu-item name="4">
                        <Icon type="heart-broken" :size="iconSize"></Icon>
                        <span class="layout-text" >流失用户</span>
                    </Menu-item>
                </Menu>
            </i-col>
            <i-col :span="spanRight">
                <div class="layout-header" style="background:#464c5b;">
                    <i-button type="text" @click="toggleClick">
                        <Icon type="navicon" size="32"></Icon>
                    </i-button>
                </div>
                <div class="layout-breadcrumb">
                    <Breadcrumb>
                        <Breadcrumb-item href="/">首页</Breadcrumb-item>
                        <Breadcrumb-item href="#">应用中心</Breadcrumb-item>
                        <Breadcrumb-item>某应用</Breadcrumb-item>
                    </Breadcrumb>
                </div>
                <div class="layout-content">
                    <router-view></router-view>
                </div>
                <div class="layout-copy">
                    2011-2016 &copy; TalkingData
                </div>
            </i-col>
        </Row>
    </div>
</template>
<script>
export default {
        data () {
            return {
                spanLeft: 4,
                spanRight: 20
            }
        },
        computed: {
            iconSize () {
                return this.spanLeft === 4 ? 16 : 24;
            }
        },
        methods: {
            toggleClick () {
                if (this.spanLeft === 4) {
                    this.spanLeft = 2;
                    this.spanRight = 22;
                } else {
                    this.spanLeft = 4;
                    this.spanRight = 20;
                }
            },
             routeTo(e) {
                    //console.log(e);
                    this.$router.push(e);
            }
        }
    }
</script>
